package 刷题10月.数组;
// https://leetcode-cn.com/problems/search-insert-position/
public class 搜索插入位置1016 {
    class Solution {
        public int searchInsert(int[] nums, int target) {
            int left=0,mid,right=nums.length-1;
            while(left<=right){
                mid=left+(right-left)/2;
                if(nums[mid]==target){
                    return mid;
                }
                else if(nums[mid]<target){
                    left=mid+1;
                }
                else
                    right=mid-1;
            }
            return left;
        }
    }
}
